package com.qyl.deguru.controller.customer;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.qyl.deguru.dto.Address;
import com.qyl.deguru.dto.User;
import com.qyl.deguru.service.AddressService;
import com.qyl.deguru.service.UserService;
import com.qyl.deguru.service.impl.AddressServiceImple;
import com.qyl.deguru.service.impl.UserServiceImpl;

/**
 * 用户页面信息
 * */
@Controller
@RequestMapping("/customer/detail")
public class UserDetailController {
	UserService userService=new UserServiceImpl();
	AddressService addService=new AddressServiceImple();
	//跳转到用户管理
	@RequestMapping("/toUserDetail")
	public String toUserDetail(String uid,ModelMap modelMap){
		User user=userService.getUserById(uid);
		modelMap.addAttribute("user", user);
		return "user";
	}
	//跳转到用户管理地址
	@RequestMapping("/toAddress")
	public String toAddress(int aid,ModelMap modelMap){
		List<Address> address=addService.getAddressByUser_id(aid);
		modelMap.addAttribute("address", address);
		return "address";
	}
	//删除地址信息
	@RequestMapping("/delAddressById")
	public String delAddressById(int did){
		addService.delAddressById(did);
		return "forward:toAddress";
		
	}
}
